package network;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class TcpDictServer extends TcpEchoServer {
    Map<String, String> dictionary = new HashMap<>();
    public TcpDictServer(int port) throws IOException {
        super(port);
        dictionary.put("hello", "你好");
        dictionary.put("banana", "香蕉");
    }

    @Override
    public String process(String request) {
        return dictionary.getOrDefault(request, "没查到");
    }

    public static void main(String[] args) throws IOException {
        TcpDictServer dictServer = new TcpDictServer(9090);
        dictServer.start();
    }
}
